﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title></title>
    <link href="../CSS/Style4.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.pager.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.showModalDialog.js" type="text/javascript"></script>
    <script type="text/javascript">
        //时间格式转换
        function date2str(date) {
            //null判断
            if (date == null) return "";
            //去掉左右的斜杠
            date = date.replace(/\//g, "");
            //将其转为一个日期对象
            eval("var d = new " + date + ";");
            //返回最终结果
            return d.getFullYear() + "年" + (d.getMonth() + 1) + "月" + d.getDate() + "日";
        }
        $(function () {
            reloadCustomer();
            reloadLinkMan();
        })
        
        //加载 Customer(客户信息) 表的全部内容
        function reloadCustomer() {
            //注册分页器控件
            $("#pageDiv").empty().pager2("QuanBuAll.asmx/paging", {}, function (data) {
                //展示查询的结果
                $("#tb1 tr:gt(0)").remove();
                var tb1 = $("#tb1").get(0);
                for (var i = 0; i < data.length; i++) {
                    var tr = tb1.insertRow(-1);
                    tr.insertCell(-1).innerHTML = data[i].CusID || "";
                    tr.insertCell(-1).innerHTML = data[i].CusName || "";
                    tr.insertCell(-1).innerHTML = date2str(data[i].CusDate) || "";
                    tr.insertCell(-1).innerHTML = data[i].CusMan || "";
                    tr.insertCell(-1).innerHTML = '<img src="../images/33.gif" title="编辑" onclick="showCustomer(' + data[i].ID + ')" />' || "";
                }
            });
        }
        //加载 LinkMan(联系人) 表的全部内容
        function reloadLinkMan() {
            //注册分页器控件
            $.ajax({
                url: "QuanBuAll.asmx/SelectLinkMans",
                type: "post",
                data: JSON.stringify({}),
                dataType: "json",
                contentType: "application/json",
                success: function (obj) {
                    $("#tb2 tr:gt(0)").remove();
                    var tb2 = $("#tb2").get(0);
                    for (var i = 0; i < obj.d.length; i++) {
                        var tr = tb2.insertRow(-1);
                        tr.insertCell(-1).innerHTML = obj.d[i].LMName || "";
                        tr.insertCell(-1).innerHTML = obj.d[i].LMSex || "";
                        tr.insertCell(-1).innerHTML = obj.d[i].LMDuty || "";
                        tr.insertCell(-1).innerHTML = obj.d[i].LMOfficeNo || "";
                        tr.insertCell(-1).innerHTML = obj.d[i].LMMobileNo || "";
                        tr.insertCell(-1).innerHTML = '<img title="编辑" src="../images/33.gif" onclick="showLinkMan(' + obj.d[i].LMID + ')" />&nbsp;&nbsp;<img title="删除" onclick="editLinkMan(' + obj.d[i].LMID + ');" src="../images/11.gif" />' || "";
                    }
                }, error: function (xmlhttp) {
                    alert("错误：" + xmlhttp.responseText);
                }
            });
        }
        //修改客户信息表
        function showCustomer(id) {

            $.showModalDialog("CustomerEdit.htm?data=" + Math.random(), { id: id }, 600, 400, function (r) {
                reloadCustomer();
            });

        }
        //添加联系人表
        function showLinkMan() {

            $.showModalDialog("LinkManAdd.htm?data=" + Math.random(), null, 600, 300, function (r) {
                reloadLinkMan();
            });
        }
    </script>
</head>
<body>
    <div id="desDiv">
        <span>客户信息管理</span><br />
        维护客户信息，记录客户联系电话和交往记录
    </div>
    <br />
    <div style="width: 1065px">
        <div id="dataLeft">
            <table class="dataTable" id="tb1">
                <tr>
                    <th>
                        客户编号
                    </th>
                    <th>
                        客户名称
                    </th>
                    <th>
                        建立时间
                    </th>
                    <th>
                        客户经理
                    </th>
                    <th>
                        操作
                    </th>
                </tr>

            </table>
            <div id="pageDiv">
                
            </div>
        </div>
        <div id="dataRight">
            <div class="menuDiv">
                <div style="background-image:url(../images/bg.gif)">暂缓流失措施
                </div>
            </div>
            <div class="contentDiv">
                <div>
                    <a href="javascript:showLinkMan()">新建联系人</a>
                    <table class="dataTable" id="tb2">
                        <tr>
                            <th>
                                姓名
                            </th>
                            <th>
                                性别
                            </th>
                            <th>
                                职位
                            </th>
                            <th>
                                固定电话
                            </th>
                            <th>
                                手机号码
                            </th>
                            <th>
                                操作
                            </th>
                        </tr>

                    </table>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
